﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Nxg.Blog.Core.Extensions
{
    public static class DateTimeExtensions
    {

        public static DateTime ToChineseTime(this DateTime dt)
        {
            //var cnOffset = TimeZoneInfo.FindSystemTimeZoneById("Asia/Shanghai").BaseUtcOffset;
            //var cnUTC = dt.Add(cnOffset);
            var cnUTC = dt.AddHours(8);
            var cnDT = new DateTime(cnUTC.Year, cnUTC.Month, cnUTC.Day, cnUTC.Hour, cnUTC.Minute, cnUTC.Second, cnUTC.Millisecond, DateTimeKind.Unspecified);
            return cnDT;
        }

        public static string ToFormatString(this DateTime dt)
        {
            return dt.ToString("yyyy-MM-dd HH:mm");
        }
    }
}
